import { Injectable } from '@angular/core';
import {LocalStorageService} from './local-storage.service';
import {CanActivateChild, ActivatedRouteSnapshot, Router, RouterStateSnapshot} from '@angular/router';

@Injectable()
export class MemberGuard implements CanActivateChild {

  constructor(private localStorageService: LocalStorageService, private router: Router) { }

  canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    if (!this.localStorageService.getUserInfo()) {

        window.location.href = "/login";
    }
    return true;
  }
}
